<div class="page_title">    
    <span class="title_icon"><span class="coverflow"></span></span>
    <h3>Pacientes</h3>    
</div>
<div id="content">
    <div class="grid_container">
        <div class="grid_12">
            <!--            <form action="#" method="post" id="form103" class="form_container left_label valid_tip">-->
            <?php echo $this->Form->create('Paciente', array('id' => "form103", 'class' => "form_container left_label valid_tip")) ?>
            <div class="widget_wrap">
                <div class="widget_top">
                    <span class="h_icon list"></span>
                    <h6>REGISTRO NUEVO PACIENTE</h6>    
                </div>
                <div class="widget_content">

                    <ul>
                        <li>
                            <div class="form_grid_12">
                                <label class="field_title">Nombres completos</label>
                                <div class="form_input">
                                    <div class="form_grid_4 alpha">
                                        <?php echo $this->Form->text('nombres', array('tabindex' => 1, 'class' => 'required')) ?>
                                        <span class=" label_intro">Nombres</span>
                                    </div>
                                    <div class="form_grid_4">
                                        <?php echo $this->Form->text('ap_paterno', array('tabindex' => 1)) ?>
                                        <span class=" label_intro">Apellido paterno</span>
                                    </div>
                                    <div class="form_grid_4">
                                        <?php echo $this->Form->text('ap_materno', array('tabindex' => 1)) ?>
                                        <span class=" label_intro">Apellido materno</span>
                                    </div>
                                    <span class="clear"></span>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form_grid_12">
                                <label class="field_title">FECHA DE NACIMIENTO Y SEXO</label>
                                <div class="form_input">
                                    <div class="form_grid_4 alpha">
                                        <input name="data[Paciente][fecha_nacimiento]" type="text" id="date" tabindex="1"/>
                                        <span class=" label_intro">fecha dd/mm/aaaa</span>
                                    </div>
                                    <div class="form_grid_5">
                                        <span>
                                            <input name="data[Paciente][sexo]" class="radio" type="radio" value="F" tabindex="1" selected>
                                            <label class="choice">Femenino</label>
                                        </span><span>
                                            <input name="data[Paciente][sexo]" class="radio" type="radio" value="M" tabindex="1">
                                            <label class="choice">Masculino</label>
                                        </span>
                                        <span class=" label_intro">SEXO</span>
                                    </div>
                                    <div class="form_grid_3">
                                        <?php //echo $this->Form->text('carnet', array())?>
                                        <input name="data[Paciente][carnet]" type="text" class="validate number" tabindex="1"/>
                                        <span class=" label_intro">CARNET DE ID</span>
                                    </div>
                                    <span class="clear"></span>
                                </div>
                            </div>

                        </li>
                        
                       <li>
                            <div class="form_grid_12">
                                <label class="field_title">Lugar de nacimiento</label>
                                <div class="form_input">
                                    <div class="form_grid_4 alpha">
                                        <?php echo $this->Form->text('pais', array('tabindex'=>2))?>
                                        <label class="label_intro"><b>Area/Alcaldia</b><span style="color:red">(<b>DEPARTAMENTO</b> "S&oacute;lo los nacidos en CIUDAD")</span></label>
                                    </div>
                                    <div class="form_grid_4">
                                        <?php echo $this->Form->text('ciudad', array('tabindex'=>2))?>
                                        <label class="label_intro"> 
                                        <b>Comunidad/Localidad</b>
                                        <span style="color:red">(
                                            <b>PROVINCIA</b>"S&oacute;lo los nacidos en CIUDAD")
                                        </span>
                                        </label>
                                    </div>                                    
                                    <span class="clear"></span>      
                                </div>
                            </div>
                        </li>
                        <li>
                        <div class="form_grid_12">
                        <label class="field_title">Profesion o carrera</label>
                        <div class="form_input">
                            <div class="form_grid_4">
                            <?php echo $this->Form->text('profesion', array('tabindex'=>3))?>
                            </div>
                            <span class="clear"></span>
                        </div>
                        </div>
                        </li>
                        <li>
                            <div class="form_grid_12">
                                <label class="field_title">Lugar de residencia actual</label>
                                <div class="form_input">
                                    <span>
                                        <input name="data[Paciente][lugar]" id="lugar1" class="radio" type="radio" value="provincia" tabindex="5" selected>
                                        <label class="choice">Provincia</label>
                                    </span>
                                    <span>
                                        <input name="data[Paciente][lugar]" id="lugar2" class="radio" type="radio" value="ciudad" tabindex="6">
                                        <label class="choice">Ciudad</label>
                                    </span>
                                </div>
                            </div>
                        </li>
                        
                        <li id="provincia">
                            <div class="form_grid_12 multiline" >
                                <label class="field_title">Lugar de residencia</label>
                                <div class="form_input">
                                    <div class="form_grid_6 alpha">
                                        <input name="data[Paciente][alcaldia]" type="text" tabindex="7"/>
                                        <span class=" label_intro">Area / Alcaldia</span>
                                    </div>
                                    <div class="form_grid_6 ">
                                        <input name="data[Paciente][localidad]" type="text" tabindex="7"/>
                                        <span class=" label_intro">Comunidad / localidad</span>
                                    </div>
                                    <span class="clear"></span>
                                </div>
                                <div class="form_input">
                                    <div class="form_grid_6 alpha">
                                        <?php echo $this->Form->text('telefono_p', array('class'=>'validate number','tabindex'=>"8"))?>
                                        <span class=" label_intro">Telefono </span>
                                    </div>
                                    <div class="form_grid_6 ">
                                        <input name="data[Paciente][celular_p]" type="text" tabindex="9"/>
                                        <span class=" label_intro">Celular </span>
                                    </div>
                                    <span class="clear"></span>
                                </div>
                                <div class="form_input">
                                    <div class="form_grid_4 alpha">
                                        <?php echo $this->Form->text('direccion_p', array('placeholder'=>'Coloque la direccion'))?>
                                        <span class=" label_intro">DIRECCION</span>
                                    </div>
                                    <div class="form_grid_4">
                                        <select data-placeholder="Seleccione el departamento..." class="chzn-select full" name="data[Paciente][departamento_id_p]" tabindex="4" id="cb_dpto">
                                            <option value=""></option>
                                            <?php foreach ($departamentos as $departamento): ?>
                                                <option value="<?php echo $departamento['Departamento']['id'] ?>">
                                                    <?php echo $departamento['Departamento']['nombre'] ?>
                                                </option>
                                            <?php endforeach; ?>
                                        </select>
                                        <span class=" label_intro">DEPARTAMENTO</span>
                                    </div>
                                    <div class="form_grid_4" id="cb_provincia">
                                        <select data-placeholder="Seleccione la provincia..." class="chzn-select full" name="data[Paciente][provincia_id]" tabindex="4">
                                            <option value=""></option>
                                            <option value="0">Provincia 1</option>		

                                        </select>
                                        <span class=" label_intro">PROVINCIA</span>
                                    </div>

                                    <span class="clear"></span>
                                </div>
                            </div>
                        </li>
                        <li id="departamento">
                            <div class="form_grid_12 multiline" >                                
                                <label class="field_title">Lugar de residencia</label>
                                <div class="form_input">
                                    
                                    <div class="form_grid_6 alpha">
                                        <input name="data[Paciente][direccion]" type="text" tabindex="4"/>
                                        <span class=" label_intro">Direcci&oacute;n</span>
                                    </div>
                                    <div class="form_grid_6 ">
                                        <input name="data[Paciente][telefono]" type="text" tabindex="4"/>
                                        <span class=" label_intro">Telefono</span>
                                    </div>
                                    <span class="clear"></span>
                                </div>
                                <div class="form_input">
                                    <div class="form_grid_6 alpha">
                                        <input name="data[Paciente][celular]" type="text" tabindex="4"/>
                                        <span class=" label_intro">Celular </span>
                                    </div>
                                    <div class="form_grid_6 ">
                                        <input name="data[Paciente][correo]" type="text" tabindex="4"/>
                                        <span class=" label_intro">E-Mail</span>
                                    </div>
                                    <span class="clear"></span>
                                </div>
                                <div class="form_input">
                                    <div class="form_grid_4 alpha">
                                        <select id="dpto_1" data-placeholder="Seleccione la provincia..." class="chzn-select full" name="data[Paciente][departamento_id]" tabindex="4">
                                            <option value=""></option>
                                            <?php foreach ($departamentos as $departamento): ?>
                                                <option value="<?php echo $departamento['Departamento']['id'] ?>">
                                                    <?php echo $departamento['Departamento']['nombre'] ?>
                                                </option>
                                            <?php endforeach; ?>
                                        </select>
                                        <span class=" label_intro">DEPARTAMENTO</span>
                                    </div>
                                    <div class="form_grid_4" id="carga_prov1">
                                        <select data-placeholder="Seleccione la provincia..." class="chzn-select full" name="data[Paciente][provincia_id]" tabindex="4">
                                            <option value=""></option>
                                            <option value="United States">Departamento 1</option>		

                                        </select>
                                        <span class=" label_intro">PROVINCIA</span>
                                    </div>

                                    <span class="clear"></span>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form_grid_12">
                                <div class="form_input">
                                    <div id="enviaDatos">
                                    <button type="submit" class="btn_small btn_blue"><span>Guardar Paciente</span></button>
                                    <button type="reset" class="btn_small btn_orange"><span>Limpiar datos</span></button>                                    
                                    <button type="submit" class="btn_small btn_gray" name="data[Paciente][sinFoto]" value="S"><span>Guarda Paciente y saca Ficha</span></button>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <li>

                        </li>
                    </ul>

                </div>
            </div>
            </form>
        </div>
        <script>
            $(document).ready(function() {
                $('#provincia').hide();
                $('#departamento').hide();
                $("#lugar1").attr('checked', false);
                $("#lugar2").attr('checked', false);

                $('#cb_dpto').change(function() {
                    if($('#lugar1').is(':checked')){
                       console.log('selecciono provincia');
                        $('#cb_provincia').load('<?php echo $this->Html->url(array('action' => 'ajaxprovinciap')) ?>/' + this.value);    
                    }else{
                        console.log('selecciono ciudad');
                        $('#cb_provincia').load('<?php echo $this->Html->url(array('action' => 'ajaxprovincia')) ?>/' + this.value);
                    }
                });
                $('#dpto_1').change(function() {
                if($('#lugar2').is(':checked')){
                       console.log('selecciono ciudad');
                         $('#carga_prov1').load('<?php echo $this->Html->url(array('action' => 'ajaxprovincia')) ?>/' + this.value);   
                    }else{
                        console.log('selecciono provincia');
                        $('#carga_prov1').load('<?php echo $this->Html->url(array('action' => 'ajaxprovinciap')) ?>/' + this.value);
                    }
                   

                });
                $('#lugar1').click(function() {
                    $('#departamento').hide();
                    $('#provincia').show('slow');

                    //$('#provincia').toggle('slow');
                });
                $('#lugar2').click(function() {
                    $('#provincia').hide();
                    $('#departamento').show('slow');

                    //$('#departamento').toggle('slow');
                });
                
                $('#enviaDatos').click(function(){
                    $('#enviaDatos').hide('slow');
                });
                
            });
            
        </script>
    </div>
    <span class="clear"></span>
</div>
